﻿using System;
using TI_BLE_HCI_ClientLib.GenericHCIEntities;
using TI_BLE_HCI_ClientLib.HCIBaseEntities;

namespace TI_BLE_HCI_ClientLib.HCIEvents
{
    public class HCIEvent_GAP_Link_Established : HCIVendorSpecificEvent
    {
        public enum DevAddrTypeEnum
        {
            AddrType_Public = 0,
            AddrType_Static = 1,
            AddrType_Private_NonResolve = 2,
            AddrType_Private_Resolve = 3
        }

        public enum ClockAccuracyEnum
        {
            ppm_500=0,
            ppm_250=1,
            ppm_150=2,
            ppm_100=3,
            ppm_75=4,
            ppm_50=5,
            ppm_30=6,
            ppm_20=7
        }

        private HCIVendorSpecificEventHostErrorCode _status;
        private DevAddrTypeEnum _devAddrType;

        private byte[] _devAddr;
        private ushort _connHandle;
        private ushort _connInterval;
        private ushort _connLatency;

        private ushort _connTimeout;

        private ClockAccuracyEnum _clockAccuracy;

        public DevAddrTypeEnum DevAddrType
        {
            get { return _devAddrType; }
            set { _devAddrType = value; }
        }
        public byte[] DevAddr
        {
            get { return _devAddr; }
            set { _devAddr = value; }
        }
        public ushort ConnHandle
        {
            get { return _connHandle; }
            set { _connHandle = value; }
        }
        public ushort ConnInterval
        {
            get { return _connInterval; }
            set { _connInterval = value; }
        }
        public ushort ConnLatency
        {
            get { return _connLatency; }
            set { _connLatency = value; }
        }
        public ushort ConnTimeout
        {
            get { return _connTimeout; }
            set { _connTimeout = value; }
        }
        public ClockAccuracyEnum ClockAccuracy
        {
            get { return _clockAccuracy; }
            set { _clockAccuracy = value; }
        }

        public HCIVendorSpecificEventHostErrorCode Status
        {
            get { return _status; }
            set { _status = value; }
        }

        public HCIEvent_GAP_Link_Established(
            HCIVendorSpecificEventHostErrorCode status,
            DevAddrTypeEnum devAddrType,
            byte[] devAddr,
            ushort connHandle,
            ushort connInterval,
            ushort connLatency,
            ushort connTimeout,
            ClockAccuracyEnum clockAccuracy)
            : base((ushort)HCIVendorSpecificEventEventOpcode.GAP_Link_Established)
        {
            _status=status;
            _devAddrType=devAddrType;
            _devAddr = devAddr;
            _connHandle = connHandle;
            _connInterval = connInterval;
            _connLatency = connLatency;
            _connTimeout = connTimeout;
            _clockAccuracy = clockAccuracy;
        }
    }
}
